<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        html, body {
            height: 100%;
            font-size: 70px;
            font-weight: 900;
            overflow: hidden;
        }

        #sign {
            position: absolute;
            width: 80%;
            bottom: 50px;
            margin-left: 10%;
            border-radius: 10px;
            cursor: pointer;
            outline: none;
            background: #d0d0d0;
            line-height: 100px;
            text-align: center;
        }

        #result {
            height: 80%;
            width: 100%;
            word-wrap: break-word;
            word-break: normal;
            overflow-y: auto;
        }

        .userinfo {
            font-size: 25px;
            text-align: center;
        }
    </style>
</head>
<body>
<div class="userinfo">
    <label><input type="radio" name="url" value="http://test.iyouqu.com.cn:8080/app/group/service.do"/>测试</label>
    <label><input type="radio" name="url" value="http://iyouqu.com.cn:8080/app/group/service.do"/>正式</label><br/>
    <input type="text" name="userid" value="328"/>
</div>
<div id="result"></div>
<div id="sign">签到</div>
</body>
<script>
    (function () {
        var xhr, url,
                msg = {
                    msgId: "APP086",
                    userName: "柯栋",
                    userId: 32,
                    groupId: 72,
                    position: "在烽火通信高新四路研发中心签到啦！",
                    longitude: "114.431882",
                    latitude: "30.453705"
                };

        document.getElementById("sign").onclick = function () {
            if (window.XMLHttpRequest) {
                url = document.getElementsByName("url")[0].value;
                msg.userId = document.getElementsByName("userid")[0].value;
                switch (msg.userId) {
                    case 328:
                        msg.userName = "柯栋";
                        break;
                    case 2302:
                        msg.userName = "王少峰";
                        break;
                }
                xhr = new XMLHttpRequest();
                xhr.onreadystatechange = function () {
                    console.log(xhr.readyState);
                    //判断对象状态是交互完成，接收服务器返回的数据
                    if (xhr.readyState == 4 && xhr.status == 200) {
                        var result = xhr.responseText;
                        console.log(JSON.parse(result));
                        document.getElementById("result").innerHTML = result;
                    }
                };
                xhr.open("POST", url, true);
                xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                xhr.send('text=' + JSON.stringify(msg));
            }
        }
    })()
</script>
</html>